/*
 * @Author: 赛罗
 * @Date: 2023-10-16 16:49:09
 * @LastEditors: 赛罗
 * @LastEditTime: 2024-03-13 14:39:16
 * @FilePath: \haixiaoke-enterprise-reconstruction\src\utils\auth.js
 * @Description:
 */
import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

const userStateKey = 'userStatus'

export function getUserState() {
  return Cookies.get(userStateKey)
}

export function setUserState(token) {
  return Cookies.set(userStateKey, token)
}

export function removeUserState() {
  return Cookies.remove(userStateKey)
}

//存储当前账号关联企业列表
export function setEnterprisesList(data){
  return localStorage.setItem('enterprisesList',JSON.stringify(data))
}
// 获取当前账号关联企业列表
export function getEnterprisesList(){
  return localStorage.getItem('enterprisesList') ? JSON.parse(localStorage.getItem('enterprisesList')) : ''
}
// 清除关联企业列表
export function removeEnterprisesList(){
  localStorage.removeItem('enterprisesList')
}

//存储当前账号关联企业列表
export function setEnterprises(data){
  return localStorage.setItem('enterprises',JSON.stringify(data))
}
// 获取当前账号关联企业列表
export function getEnterprises(){
  return localStorage.getItem('enterprises') ? JSON.parse(localStorage.getItem('enterprises')) : ''
}
// 清除关联企业列表
export function removeEnterprises(){
  localStorage.removeItem('enterprises')
}


